home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Drawing / RegionObject.h < prev    next >
Text File  |  1997-06-28  |  3KB  |  81 lines

  1. // RegionObject.h
  2.  
  3. #ifndef RegionObject_h
  4. #define RegionObject_h
  5.  
  6. #ifndef Rectangle_h
  7. #include "Rectangle.h"
  8. #endif
  9.  
  10. class RegionObject
  11.   {
  12.     private:
  13.         RgnHandle me;
  14.         
  15.         static RegionObject& Temporary( const Rect& );
  16.         static RegionObject& Temporary( RgnHandle );
  17.         
  18.     public:
  19.         RegionObject();
  20.         RegionObject( RgnHandle );
  21.         RegionObject( const RegionObject& );
  22.         RegionObject( const Rect& );
  23.         
  24.         ~RegionObject()                                        { DisposeRgn( me ); }
  25.         
  26.         void BeEmpty()                                            { SetEmptyRgn( me ); }
  27.         
  28.         void operator=( const Rect& r )                    { RectRgn( me, &r ); }
  29.         void operator=( RgnHandle r )                        { CopyRgn( r, me ); }
  30.         void operator=( const RegionObject& r )        { CopyRgn( r, me ); }
  31.         
  32.         void operator&=( const Rect& r );
  33.         void operator|=( const Rect& r );
  34.         void operator^=( const Rect& r );
  35.         void operator-=( const Rect& r );
  36.         void Complement( const Rect& r );
  37.         
  38.         void operator&=( RgnHandle r )                    { SectRgn( me, r, me ); }
  39.         void operator|=( RgnHandle r )                    { UnionRgn( me, r, me ); }
  40.         void operator^=( RgnHandle r )                    { XorRgn( me, r, me ); }
  41.         void operator-=( RgnHandle r )                    { DiffRgn( me, r, me ); }
  42.         void Complement( RgnHandle r )                    { DiffRgn( r, me, me ); }
  43.         
  44.         void operator+=( Point vector )                    { OffsetRgn( me, vector.h, vector.v ); }
  45.         void operator-=( Point vector )                    { OffsetRgn( me, -vector.h, -vector.v ); }
  46.  
  47.         void Inset( int16 amount )                            { InsetRgn( me, amount, amount ); }
  48.         void Inset( Point amount )                            { InsetRgn( me, amount.h, amount.v ); }
  49.         void Outset( int16 amount )                        { InsetRgn( me, -amount, -amount ); }
  50.         void Outset( Point amount )                        { InsetRgn( me, -amount.h, -amount.v ); }
  51.  
  52.         void GlobalToLocal();
  53.         void LocalToGlobal();
  54.         
  55.         Rectangle Bounds() const                            { return (*me)->rgnBBox; }
  56.         operator RgnHandle() const                            { return me; }
  57.         
  58.         bool IsEmpty() const                                    { return EmptyRgn( me ); }
  59.         bool Contains( Point p ) const                    { return PtInRgn( p, me ); }
  60.         bool Rectangular() const                            { return (*me)->rgnSize == 10; }
  61.  
  62.         bool Intersects( const Rect& r ) const;
  63.         bool Intersects( const RgnHandle r ) const;
  64.         
  65.         bool operator==( const Rect& r ) const;
  66.         bool operator!=( const Rect& r ) const            { return !(*this == r); }
  67.         bool operator<=( const Rect& r ) const;
  68.         bool operator>=( const Rect& r ) const;
  69.         bool operator<( const Rect& r ) const            { return *this <= r && *this != r; }
  70.         bool operator>( const Rect& r ) const            { return *this >= r && *this != r; }
  71.         
  72.         bool operator==( RgnHandle r ) const            { return EqualRgn( me, r ); }
  73.         bool operator!=( RgnHandle r ) const            { return !EqualRgn( me, r ); }
  74.         bool operator<=( RgnHandle r ) const;
  75.         bool operator>=( RgnHandle r ) const;
  76.         bool operator<( RgnHandle r ) const                { return *this <= r && *this != r; }
  77.         bool operator>( RgnHandle r ) const                { return *this >= r && *this != r; }
  78.   };
  79.  
  80. #endif
  81.